# -*- coding: utf-8 -*-
# @Time    : 2020/3/2 14:23
# @Author  : Damn7Kx
# @Software: PyCharm
import requests
from urllib.parse import parse_qsl
from tools.utils import Utils
import json
url = "https://app.peopleapp.com/Api/700/ArtInfoApi/getArticleData"
# url = "https://app.peopleapp.com/Api/700/CommentApi/getComment"

# 列表页
# payload_base = "article_category_id=5222161&articleid=5124485&citycode=0471&comment_type=0&comment_version=v4&device=a2354a1b-6007-3487-b275-7f9279bfbbc9&device_model=G011A&device_os=Android%207.1.2&device_product=google&device_size=720*1280&device_type=1&district=%E5%9B%9E%E6%B0%91%E5%8C%BA&fake_id=35237037&interface_code=7142&latitude=40.81044856694489&longitude=111.66125353024066&max_id=0&page=1&pagesize=20&province=%E5%86%85%E8%92%99%E5%8F%A4%E8%87%AA%E6%B2%BB%E5%8C%BA&province_code=970842&type=1&user_id=10086&version=7.1.4.2"
# 详情页
payload_base = "article_id=rmh11872399&city=%E5%91%BC%E5%92%8C%E6%B5%A9%E7%89%B9%E5%B8%82&citycode=0471&components_id=0&device=a2354a1b-6007-3487-b275-7f9279bfbbc9&device_model=G011A&device_os=Android%207.1.2&device_product=google&device_size=720*1280&device_type=1&district=%E5%9B%9E%E6%B0%91%E5%8C%BA&fake_id=35237037&interface_code=7142&latitude=40.81044856694489&longitude=111.66125353024066&province=%E5%86%85%E8%92%99%E5%8F%A4%E8%87%AA%E6%B2%BB%E5%8C%BA&province_code=2269074&type=2&user_gov_id=0&user_id=0&version=7.1.4.2"
dict_payload = dict(parse_qsl(payload_base))
cipher = [i for i in dict_payload.values()]
cipher = '|'.join(cipher) + "rmrbsecurity$#%sut49fbb427a508bcc"
securitykey= Utils.md5_encrypt(cipher)
payload = payload_base+f"&securitykey={securitykey}"
# print(securitykey)

headers = {
  'User-Agent': 'Dalvik/2.1.0 (Linux; U; Android 7.1.2; G011A Build/N2G48H);DailyNewspaper/7.1.4.2',
  'Content-Type': 'application/x-www-form-urlencoded',
  'Host': 'app.peopleapp.com',
  'Connection': 'Keep-Alive',
  'Accept-Encoding': 'gzip'
}


response = requests.request("POST", url, headers=headers, data=payload)
print(json.loads(response.text))
